import {instance} from "./axios";

export function auth() {
    return instance({
        method: 'get',
        url: '/api/auth',
        headers: {
            'Content-Type': 'application/json',
        },
    })
}
export function login(form){
    return instance({
        data:form,
        method: "post",
        url: "/api/login",
    })
}

/**
 *
 * @param params {Object} 包含 num 第几页 size 每页多少个
 * @return {*}
 */
export function getGoodsList(params) {
    return instance({
        method: 'get',
        url: '/api/goods',
        headers: {
            'Content-Type': 'application/json',
        },
        params
    })
}

export function getGoodsListByKeyWords(keyword) {
    return instance({
        method: 'get',
        url: '/api/goods/keywords/' + keyword,
        headers: {
            'Content-Type': 'application/json',
        },
    })
}

export function updateGoods(goods) {
    return instance({
        method: 'post',
        url: '/api/goods/update',
        headers: {
            'Content-Type': 'application/json',
        },
        data: {
            goods: goods,
        }
    })
}

export function addGoods(goods) {
    //因为插入数据时id属于自增 所以不需要
    delete goods.goods_id
    return instance({
        method: 'post',
        url: '/api/goods/add',
        headers: {
            "Content_Type": "application/json"
        },
        data: {
            goods: goods
        }
    });
}

export function getSetting() {
    return instance({
        method: 'get',
        url: '/api/setting'
    })
}

export function setSetting(json) {

    return instance({
        method: 'post',
        url: "/api/setting",
        data: {
            json: json
        }
    })
}

export function uploadSingle(data) {
    return instance({
        url: "/api/upload",
        method: "POST",
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data
    })
}
